<?
define('_VIEW_MODEL_','default');
require_once './init.php';
header("Content-type:text/vnd.wap.wml;charset=utf-8");
$id=intval($id);
$stip = "";
if(isset($act)&&$act == "updatepssword"){
	$info = $db->GetRow("select `password`,`phone` from {$telper}user where id = '$id'");
	if(preg_match("/^[0-9]*$/",$mobile)&&strlen($mobile)==11){
		$ps = md5($oldpassword);
		if($ps == $info['password']){
			if(!empty($password1)&&$password1 == $password2){
				$newpass = md5($password1);
				$db->Execute("update {$telper}user set `password` = '$newpass' where id = '$id'");
				header("Location:bookhouse.php?id=$id");
				exit;
			}else{
				header("Location:exitpassword.php?id=$id&wrong=new");
				exit;
			}
		}else{
			header("Location:exitpassword.php?id=$id&wrong=old");
			exit;
		}
	}else{
		header("Location:exitpassword.php?id=$id&wrong=num");
		exit;
	}
}
if(isset($wrong)&&$wrong=="new"){
	$stip = "新密码输入错误";
}
if(isset($wrong)&&$wrong=="old"){
	$stip = "旧密码输入错误";
}
if(isset($wrong)&&$wrong=="num"){
	$stip = "新手机格式错误";
}
$smartyObj->assign("stip",$stip);
$smartyObj->assign("id",$id);
$smartyObj->display("exitpassword.tpl");
?>